'use strict';

const { Controller } = require('egg');

class HomeController extends Controller {
  async test() {
    const {ctx} = this;
    ctx.body = '123666'
  }

  async test_sql(){
    var data1 = await this.app.mysql.query("select *from disease")
    this.ctx.body=data1
  }


  async searcher(){
    let search_word = this.ctx.request.query.search_word
    let search_table = this.ctx.request.query.search_table
    console.log(search_word);
    if(search_table=="查疾病"){
      search_table="disease"
    }
    if(search_table=="查医院"){
      search_table="hospital_zh"
    }
    let mydata= await this.app.mysql.query(`select * from ${search_table} WHERE name LIKE '%${search_word}%'`)
    this.ctx.body=mydata
  }

  async get_doctor(){
    let doctor_tag = this.ctx.request.query.doctor_tag
    console.log(doctor_tag);
    let mydata= await this.app.mysql.query(`select * from doctor_card WHERE tag LIKE '%${doctor_tag}%'`)
    this.ctx.body=mydata
  }
}

module.exports = HomeController;
